<template>
	<view>
		<detailInfo :item="detail"/>
		
		<!-- 评论 -->
		<view class="uni-comment-title">
			最新评论 {{ comment.count }}
		</view>
		<view class="uni-comment u-comment">
			<block v-for="(item,index) in comment.list" :key="index">
				<commentList :item="item" :index="index" />
			</block>
		</view>
		
		<!-- 占位符 -->
		<view style="height:120upx;"></view>
		
		<!-- 聊天输入框 -->
		<user-chat-bottom @textSubmit="textSubmit"/>
		
		<!-- 分享 -->
		<moreShare :show="shareshow" @toggle="toggle" />
	</view>
</template>

<script>
	import detailInfo from '../../components/detail/detail-info.vue';
	import commentList from '../../components/detail/comment-list.vue';
	import userChatBottom from '../../components/user-chat/user-chat-bottom.vue';
	import moreShare from '../../components/common/more-share.vue';
	import time from '../../common/time.js';
	export default {
		data() {
			return {
				shareshow: false,
				comment:{
					count:20,
					list:[
						// 一级评论
						{   
							id:1,
							userpic:'../../static/demo/userpic/12.jpg',
							username:'哈哈',
							time:'1555400035',
							data:'今天吃什么?',
							fid:0,
						},
						// 子级评论
						{
							id:2,
							userpic:'../../static/demo/userpic/12.jpg',
							username:'哈哈',
							time:'1555400035',
							data:'今天吃什么?',
							fid: 1,
						},
						{
							id:3,
							userpic:'../../static/demo/userpic/12.jpg',
							username:'哈哈',
							time:'1555400035',
							data:'今天吃什么?',
							fid: 1,
						},
						{
							id:4,
							userpic:'../../static/demo/userpic/12.jpg',
							username:'哈哈',
							time:'1555400035',
							data:'今天吃什么?',
							fid:0,
						},
						{
							id:5,
							userpic:'../../static/demo/userpic/12.jpg',
							username:'哈哈',
							time:'1555400035',
							data:'今天吃什么?',
							fid:4,
						},
					],
					
				},
				detail:{
					userpic:"../../static/demo/userpic/12.jpg",
					username:"哈哈",
					sex:0, //0 男 1 女
					age:25,
					isguanzhu:false,
					title:"我是标题",
					titlepic:"../../static/demo/datapic/13.jpg",
					morepic:[
						"../../static/demo/datapic/13.jpg",
						"../../static/demo/datapic/14.jpg",
						"../../static/demo/datapic/15.jpg"
					],
					video:false,
					share:false,
					path:"深圳 龙岗",
					sharenum:20,
					commentnum:30,
					goodnum:20
				}
			}
		},
		onLoad(e){
			console.log('onLoad参数：',JSON.parse(e.detailData));
			this.initData(JSON.parse(e.detailData));
			this.getcomments();
		},
		// 监听导航按钮，这里只用处理右边的即可
		onNavigationBarButtonTap(e) {
			if(e.index == 0){
				console.log('分享');
				this.toggle();
			}
		},
		methods: {
			// 初始化数据
			initData(obj){
				//修改窗口标题
				uni.setNavigationBarTitle({
					title: obj.title
				})
			},
			//获取评论
			getcomments(){
				this.comment.list.forEach(v => v.time = time.gettime.gettime(v.time));
			},
			textSubmit(text){
				console.log('发言==',text);
			},
			toggle(){
				this.shareshow = !this.shareshow;
			}
		},
		components:{
			detailInfo,
			commentList,
			userChatBottom,
			moreShare
		}
	}
</script>

<style scoped>
.u-comment{
	padding: 0 20upx;
}
.uni-comment-title{
	padding: 20upx;
	font-size: 30upx;
	font-weight: bold;
}
</style>
